package com.hxc.web.controller.interest;

import java.util.List;

import com.hxc.common.core.domain.entity.SysUser;
import com.hxc.common.core.domain.model.LoginUser;
import com.hxc.common.utils.ServletUtils;
import com.hxc.framework.web.service.TokenService;
import com.hxc.interest.vo.SigninParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hxc.common.annotation.Log;
import com.hxc.common.core.controller.BaseController;
import com.hxc.common.core.domain.AjaxResult;
import com.hxc.common.enums.BusinessType;
import com.hxc.interest.domain.TReactionBack;
import com.hxc.interest.service.ITReactionBackService;
import com.hxc.common.utils.poi.ExcelUtil;
import com.hxc.common.core.page.TableDataInfo;

/**
 * 政务反馈信息Controller
 * 
 * @author hxc
 * @date 2021-08-18
 */
@Api(tags = "政务反馈管理")
@RestController
@RequestMapping("/interest/back")
public class TReactionBackController extends BaseController
{
    @Autowired
    private ITReactionBackService tReactionBackService;
    @Autowired
    private TokenService tokenService;

    /**
     * 查询政务反馈信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TReactionBack tReactionBack)
    {
        startPage();
        List<TReactionBack> list = tReactionBackService.selectTReactionBackList(tReactionBack);
        return getDataTable(list);
    }

    /**
     * 导出政务反馈信息列表
     */
    @Log(title = "政务反馈信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TReactionBack tReactionBack)
    {
        List<TReactionBack> list = tReactionBackService.selectTReactionBackList(tReactionBack);
        ExcelUtil<TReactionBack> util = new ExcelUtil<TReactionBack>(TReactionBack.class);
        return util.exportExcel(list, "政务反馈信息数据");
    }

    /**
     * 获取政务反馈信息详细信息
     */
    @ApiOperation(value = "查询政务反馈信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tReactionBackService.selectTReactionBackById(id));
    }

    /**
     * 新增政务反馈信息
     */
    @ApiOperation(value = "新增政务反馈信息")
    @Log(title = "政务反馈信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TReactionBack tReactionBack)
    {
        //用户信息
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        SysUser user = loginUser.getUser();
        tReactionBack.setUserId(user.getUserId());
        return toAjax(tReactionBackService.insertTReactionBack(tReactionBack));
    }

    /**
     * 修改政务反馈信息
     */
    @ApiOperation(value = "修改政务反馈信息")
    @Log(title = "政务反馈信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TReactionBack tReactionBack)
    {
        return toAjax(tReactionBackService.updateTReactionBack(tReactionBack));
    }

    /**
     * 删除政务反馈信息
     */
    @ApiOperation(value = "删除政务反馈信息")
    @Log(title = "政务反馈信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tReactionBackService.deleteTReactionBackByIds(ids));
    }

    @ApiOperation(value = "查询是否在签到位置")
    @GetMapping("/querySignin")
    public AjaxResult querySignin(SigninParam param){
        return tReactionBackService.querySignin(param);
    }
}
